#include <mips/regdef.h>
/*
int mystrcmp(char*str1,char*str2);
*/
	.text
	.align 2
	.globl mystrcmp
	.ent mystrcmp
mystrcmp:
/*stack:
36 a1 char*
32 a0 char*
----mi frame----
28 ---
24 ra
20 fp
16 gp
------args------
12 --
8  --
4  --
0  --
----------------
*/
/* inicializacion del frame */
	.frame $fp,32,ra
	.set noreorder
	.cpload t9
	.set reorder
	subu sp,sp,32
	.cprestore 16
	sw ra,24(sp)
	sw $fp,20(sp)
	sw gp,16(sp)
	move $fp,sp
	sw a0,32($fp)
	sw a1,36($fp)

bucle:	lb t0,0(a0)   /* t0 = *str1;t1 = *str2 */
	lb t1,0(a1)
	subu v0,t0,t1 /* resultado = t0 - t1*/
	beqz t0,salir /* t0 == 0  or t1 == 0  -> fin*/
	beqz t1,salir
	addiu a0,a0,1
	addiu a1,a1,1
	beqz v0,bucle /* resultado != 0 -> termina la comparacion*/
salir:
	move sp,$fp
	lw $fp,20(sp)
	lw ra,24(sp)
	addu sp,sp,32
	jr ra
	.end mystrcmp
